/*
  que.cpp
*/

#include <inttypes.h>
#include "que.h"

void enque(que *Q, uint8_t x){
    int i;
    (*Q).select = 0;
    for (i = 0; i < COMMAND_SIZE-1; ++i){
        (*Q).data[i] = (*Q).data[i+1];
    }
    (*Q).data[COMMAND_SIZE-1] = x;
}

uint8_t deque(que *Q){
    int temp;
    (*Q).select = 0;
    temp = (*Q).data[0];
    enque(Q,0);
    return temp;
}

void peekReset(que *Q){
    (*Q).select = 0;
}

uint8_t peek(que *Q){
    int temp = (*Q).data[(*Q).select];
    (*Q).select++;
    if ((*Q).select > COMMAND_SIZE-1){
        (*Q).select = 0;
    }
    return temp;
}

void makeEmpty(que *Q){
    int i;
    (*Q).select = 0;
    for (i = 0; i < COMMAND_SIZE; ++i){
        (*Q).data[i] = 0;
    }
}

#ifdef PC
void printQue(que Q){
    int i;
    for (i = 0; i < COMMAND_SIZE; ++i){
        printf("%u ",Q.data[i]);
    }
    printf("\n");
}
#endif

